Skip to content

fix: repair failing tests and type errors across api and shared packages - #101

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2504-1784996607
Open

fix: repair failing tests and type errors across api and shared packages#101
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2504-1784996607

Conversation

@stooit

@stooit stooit commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and TypeScript errors so bun test && bunx tsc --noEmit is fully green (22 pass, 0 fail; tsc clean).

Root causes spanned both packages:

  • shared/types.tsUser.userName renamed to username to match the contract the tests (and API routes) expect.
  • shared/utils/pagination.tspaginate() was an unimplemented stub that threw "not implemented"; implemented it to satisfy the full test contract (1-based paging, partial last page, out-of-range → empty data, correct total/totalPages).
  • api/routes/users.tsbadRequest was used but never imported; added it to the ../lib/errors import.
  • api/middleware/auth.ts — case-sensitive HTTP-method check compared a lowercase 'post' against Hono's uppercase c.req.method, so POST /users wasn't treated as public; fixed literal to 'POST'.
  • tsconfig.json — added "types": ["bun-types"] (already installed) to resolve Cannot find module 'bun:test' and the process global. No new dependencies added.

Verification

  • bun test → 22 pass, 0 fail across 4 files
  • bunx tsc --noEmit → clean (exit 0)

Notes / assumptions

  • No test files were modified; canonical field spelling (username) was derived from the tests.
  • The username rename was verified consistent across all source usages — no userName remains anywhere in source or tests.
  • Minor untested edge case flagged in review: paginate(..., size=0) yields totalPages: Infinity. Not exercised by any test and pageSize isn't user-controlled in current routes, so left unguarded to stay within scope.

- shared: rename User.userName to username to match test contract
- shared: implement paginate() utility (was an unimplemented stub)
- api: import badRequest into users route (missing import)
- api: fix case-sensitive HTTP method check in auth middleware ('post' -> 'POST')
- tsconfig: add bun-types to resolve 'bun:test' module and 'process' global
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant